<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/element.css" rel="stylesheet"/>
    <link href="../css/styleindex.css" rel="stylesheet"/>
    <link href="../css/swiper.min.css" rel="stylesheet"/>
    <style>
    .layui-laydate{
      width: 100%!important;
    }.layui-laydate-main{
      width: 100%!important;
    }
    .layui-laydate-content table{
      width: 100%!important;
    }
    </style>
</head>
<body style="background:#EFF0F4;">

  <div class="mui-content">
    <div id="vm" class="x-examok" v-cloak>
      <!--  -->
      <div class="x-trtali-box" id="calali" style="margin:1rem"></div>
      <!--  -->
      <div class="x-train-tabs swiper-container">
        <div class="swiper-wrapper">
          <div class="swiper-slide x-train-items" v-for="(item,index) in tabsdata" :key="item.id" @click="changetab(index,item.id)" :class="{active:curId==index}">{{item.title}}</div>
        </div>
      </div>
      <!--  -->
      <div class="x-train-tb">
        <div class="x-train-tabs swiper-containertwo">
          <div class="swiper-wrapper">
            <div class="swiper-slide x-train-items" v-for="(item,index) in tabsdatatwo" :key="item.id" @click="changetabtwo(index,item.id)" :class="{active:curIdtwo==index}">{{item.date_split}}</div>
          </div>
        </div>
        <template>
          <el-table :data="tabledata">
            <el-table-column label="序号" width="50" type="index" fixed></el-table-column>
            <el-table-column label="项目" width="" fixed>
              <template slot-scope="scope">
                {{scope.row.content}}
              </template>
            </el-table-column>
            <el-table-column label="检查结果" width="120">
              <template slot-scope="scope">
                <div v-if="scope.row.is_ok=='0'" size="mini">未确认</div>
                <div v-if="scope.row.is_ok=='1'" size="mini" class="x-text-g">已完成</div>
                <div v-if="scope.row.is_ok=='2'" size="mini" class="x-text-r">未完成</div>
              </template>
            </el-table-column>
            <el-table-column label="记录要点" width="">
              <template slot-scope="scope">
                <el-button type="text" size="mini" @click="editfavo(scope.row.id)">查看</el-button>
              </template>
            </el-table-column>
          </el-table>
        </template>
      </div>
      <!--  -->
      <!--  -->
      <el-dialog title="" :visible.sync="edittoast" width="90%" center="true" close-on-click-modal="false" show-close="false">
        <div class="x-pro-row">
          <div class="x-pro-label">添加文字：</div>
          <div class="x-pro-input">
            <el-input placeholder="请输入" v-model="textvalue" type="textarea" :rows="3" :disabled="isfromindex"></el-input>
          </div>
        </div>
        <div class="x-pro-row">
          <div class="x-pro-label">添加图片：</div>
          <div class="x-pro-input">
            <el-button type="success" :disabled="isfromindex">添加图片</el-button>
          </div>
        </div>
        <div class="x-pro-himg" :style="{'background-image':'url(' +input4+ ')','background-size':'cover','width':'6rem','height':'6rem','border-radius':'0.4rem','margin-top':'1rem'}" v-if="input4!=''" @click="imagebig = true"></div>
        <span slot="footer" class="dialog-footer">
          <div class="x-pro-gobtn" v-show="!isfromindex">提交</div>
        </span>
      </el-dialog>
      <img :src="input4" alt="" width="100%" v-if="imagebig" class="x-img-big" @click="imagebig = false">
    </div>
  </div>

  <script type="text/javascript" src="../script/vue.js"></script>
  <script type="text/javascript" src="../script/element.js"></script>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/base.js"></script>
  <script type="text/javascript" src="../script/swiper.min.js"></script>
  <script type="text/javascript" src="../script/laydate/laydate.js"></script>
	<script>
apiready = function () {
    $api.fixStatusBar($api.byId('header'));


    //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
          thmonth:'',
          tabsdata:'',
          tabsdatatwo:'',
          curId:0,
          curIdtwo:0,
          tabsid1:'',
          tabsid2:'',
          tabledata:[],
          edittoast:false,
          isfromindex:false,
          textvalue:'',
          input4:'',
          imagebig:false

        }
      },
      created:function() {
        var that=this;


      },
      mounted:function(){
        var that=this;
        laydate.render({
          elem: '#calali',
          position: 'static',
          btns:['now'],
          format:'yyyyMMdd',
          // theme:'#058142',
          change:function(value,date){
            console.log(value);
            that.thmonth = value;
            that.gettrainadmin()
          }
        });
        //当前月份
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth()+1;
        var day = date.getDate()
        if(month<10){
          month = '' + 0 + month;
        }
        if(day<10){
          day = '' + 0 + day;
        }
        var toMonth = '' + year +  month +  day;
        that.thmonth = toMonth;
        that.gettrainadmin()
      },
      methods: {
        //列表
        gettrainadmin:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/duty/check',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                cateid:that.tabsid1,
                timeid:that.tabsid2,
                _ssid:$api.getStorage('jobid')
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                  that.tabsdata = ret.data.cate;//tabs1
                  that.tabsdatatwo = ret.data.times;//tabs2
                  that.tabledata = ret.data.list;
                  that.checkstr = ret.data.check_str;
                  var nunum;
                  if(that.tabsdata.length<3){
                    nunum = 2;
                  }else{
                    nunum = 3;
                  }
                  that.$nextTick(function(){
                    var mySwiper = new Swiper('.swiper-container',{
                      freeMode: true,
                      loop:false,//设置 active slide 居中后，会有左右留白现象，添加此会让未尾的导航补齐前后空白
                      slideToClickedSlide: true,//设置为true则点击slide会过渡到这个slide。
                      slidesPerView: nunum,
                      centeredSlides: false,//设定为true时，active slide会居中，而不是默认状态下的居左。
                      spaceBetween: 10,//slide之间设置距离
                      slidesOffsetBefore: 0,//设定slide与左边框的预设偏移量
                      slidesOffsetAfter: 0,//设定slide与右边框的预设偏移量

                    });
                    var mySwiper = new Swiper('.swiper-containertwo',{
                      freeMode: true,
                      loop:false,//设置 active slide 居中后，会有左右留白现象，添加此会让未尾的导航补齐前后空白
                      slideToClickedSlide: true,//设置为true则点击slide会过渡到这个slide。
                      slidesPerView: 2,
                      centeredSlides: false,//设定为true时，active slide会居中，而不是默认状态下的居左。
                      spaceBetween: 10,//slide之间设置距离
                      slidesOffsetBefore: 0,//设定slide与左边框的预设偏移量
                      slidesOffsetAfter: 0,//设定slide与右边框的预设偏移量

                    });

                  });
              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //切换选项卡1
        changetab:function(index,id){
          var that = this;
          that.curId = index;
          that.tabsid1 = id;
          that.gettrainadmin()
      		// mySwiper.slideToLoop(index, 500, false);
        },
        //切换选项卡2
        changetabtwo:function(index,id){
          var that = this;
          that.curIdtwo = index;
          that.tabsid2 = id;
          that.gettrainadmin()
      		// mySwiper.slideToLoop(index, 500, false);
        },
        //记录要点
        editfavo:function(id){
          var that = this;
          that.textvalue = '';
          that.input4 = '';
          that.editid = id;
          that.showedit()


        },
        //要点回显
        showedit:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/duty/getLog',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                id:that.editid,
                _ssid:$api.getStorage('jobid')
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                if(ret.data==''){
                  api.toast({
                      msg: '暂无记录要点',
                      duration: 3000,
                      location: 'bottom'
                  });
                }else{
                  that.edittoast = true;
                  that.textvalue = ret.data.content;
                  that.input4 = ret.data.img;
                }



              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
      }
    })
	}


	</script>
</body>
</html>
